import { Dayjs } from "dayjs";
import { ReceiptStatus } from "/@/api/main/pis/models";

export enum InvoiceType {
  normal = 0,
  pro = 1,
}

export enum PayOpType {
  pay = 0,
  collect = 1,
}

export enum PayRecMethod {
  bankTransfer = 0,
}

export enum FinancialType {
  payment = "payment",
  checkBill = "checkBill",
}

export interface FinancialItem {
  id: number;
  //invoice
  invoiceNum: string;
  invoicingDate: number;
  _invoicingDate: Dayjs | null;
  invoiceType: InvoiceType;
  invoiceCode: string;
  supplierId: number | null;
  supplierName: string;
  invoiceAmount: number | null;
  invoiceUrl: string;
  //payment
  orderNo: string;
  settlementId: number;
  settlementOrderNo: string;
  opType: PayOpType;
  payRecDate: number;
  _payRecDate: Dayjs | null;
  // supplierId: number;
  invoiceId: number | null;
  payRecAmount: number | null;
  payRecMethod: PayRecMethod;
  voucherNum: string;
  voucherUrl: string;
  //checkBill
  reconciliationPeriod: string;
  docNum: number | null;
  billsNum: number | null;
  totalBillAmount: number | null;
  confirmedBillQuantity: number | null;
  confirmedBillAmount: number | null;
  invoicedAmount: number | null;
  settledAmount: number | null;
  unsettledAmount: number | null;
  pushTime: number;
  pusher: string;
  _proposedSettlementDate: Dayjs | null;
  proposedSettlementDate: number;
  details: Partial<DocItem>[] | null;
  _details: {
    startPeriod: number;
    endPeriod: number;
    details: Partial<DocItem>[];
  } | null;
  startPeriod: number | null;
  endPeriod: number | null;
  //settlement
  settlementNo: number;
  reconciliationId: number;
  reconciliationOrderNo: string;
  invoiceDate: number;
  quantity: number;
  amount: number;
  //common
  remark: string;
  tabulator: string;
  tabulationTime: number;
  reviewTime: number;
  reviewer: string;
  status: ReceiptStatus;
}

export enum DocType {
  warehousing = 0,
  exWarehouse = 1,
}

export interface DocItem {
  _uuid?: string;
  id: number;
  reconciliationId: number;
  orderId: number;
  type: DocType;
  orderNo: string;
  refOrderNo: string;
  supplierName: string;
  supplierId: number;
  warehouse: string;
  createTime: number;
  quantity: number;
  amount: number;
  remark: string;
  tabulator: string;
  tabulationTime: number;
  reviewTime: number;
  reviewer: string;
}

export interface DetailModalOptions {
  triggerKeys: string[];
  title: string;
  loading: boolean;
  data: Partial<FinancialItem>;
  desKeys: (
    | string
    | {
        key: string;
        isDate?: boolean;
        customRender?: (value: any) => string;
        enumInfo?: { enumData: any; localKey: string };
      }
  )[];
}
